using System.Windows;

namespace Monti.MVVM.Services
{
   /// <summary>
   /// Default implementation of a message box service.
   /// </summary>
   public class MessageBoxService : IMessageBoxService
   {
      /// <summary>
      /// Shows a dialog asking the user to answer yes or no.
      /// </summary>
      /// <param name="message">Message to put in dialog.</param>
      /// <param name="caption">Caption for dialog, default is 'Yes or No?'</param>
      /// <returns>True if the user pressed yes, False if no was pressed.</returns>
      public bool ShowYesNo (string message, string caption = "Yes or No?")
      {
         var result = MessageBox.Show (Application.Current.MainWindow,
            message, caption, MessageBoxButton.YesNo, MessageBoxImage.Question);
         return (result == MessageBoxResult.Yes);
      }
      
      /// <summary>
      /// Shows an error dialog.
      /// </summary>
      /// <param name="message">Message to put in dialog.</param>
      /// <param name="caption">Caption for dialog, default is 'Error'</param>
      /// <returns>True if the user pressed yes, False if no was pressed.</returns>
      public void ShowError (string message, string caption = "Error")
      {
         MessageBox.Show (Application.Current.MainWindow,
            message, caption, MessageBoxButton.OK, MessageBoxImage.Error);
      }
   }
}